<?php
error_reporting( E_ALL&~E_NOTICE );
ini_set( 'display_errors', 'off' );//屏蔽错误和警告提示
include("mysql.php");
if(isset($_GET['name']) and isset($_GET['pwd']))
{
$name=$_GET['name'];
$pwd=sha1(htmlentities($_GET['pwd']));
$check="SELECT * FROM  `user` WHERE  `name` =  '$name'";
$ret=mysql_query($check);
$row=mysql_fetch_array($ret);
//echo $row['pwd'];
//if($ret)
if($row['sta']==1){
        echo'当前账户已被封号';
        exit;
    }
if($row['pwd']==$pwd)
{       $id=$row['id'];
        logo_s_time($id);
        $login_time=user_time($id); //到期时间
        if($login_time!=False){
        echo'登录成功!<br>到期时间为'.$login_time;
        }
        else{
            echo "登录失败！账户已过期，请充值";
        }
}

else{
    echo '登录失败!用户名或密码错误';
    exit;
}
}


function logo_s_time($id){ //修改活跃时间
$mysql="UPDATE  `user` SET  `s_time` =  NOW() WHERE  `id` =$id;"; 
$ret=mysql_query($mysql);
}
function user_time($id){ //是否到期
$mysql="SELECT * FROM  `user` WHERE  `id` =$id"; 
$ret=mysql_query($mysql);
if($ret){
$row=mysql_fetch_array($ret);
//echo (strtotime($row['time'])-28800).'---'.time();
if((strtotime($row['time'])-28800)>time()){
    return $row['time'];
   exit;
}
else{
    return False; 
}
}
}

?>